﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using TransactionServer.General_Classes;

namespace TransactionServer.OSActivities
{

    public sealed class OSGetContactInfo : CodeActivity
    {
        // Define an activity input argument of type string
        public InArgument<Context> Context { get; set; }
        public InArgument<string> Connection { get; set; }
        public InArgument<string[]> Attributes { get; set; }
        public InArgument<string> Type { get; set; }
        public InArgument<string> KindCode { get; set; }
        public InArgument<string> ObjectId { get; set; }
        public OutArgument<Entity> Target { get; set; }

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            var con = context.GetValue(this.Context);
            var connection = context.GetValue(this.Connection);
            var attributes = context.GetValue(this.Attributes);
            var type = context.GetValue(this.Type);
            var kind = context.GetValue(this.KindCode);
            var objectId = context.GetValue(this.ObjectId);

            OSConnector conn = (OSConnector)con.Connector[connection];

            var value = conn.getContactInfo(objectId, type, kind, attributes);

            context.SetValue(this.Target, value);


        }
    }
}
